# Gilardi, Fabrizio, "The Temporary Importance of Role Models for Women's Political Representation", American Journal of Political Science
# Code to replicate SI3 (descriptive statistics)
# gilardi@ipz.uzh.ch, 2014-06-23

# Set working directory
setwd("../Data/")

# Load packages
library(xtable)

# Load data
d <- read.csv("dataset-full.csv")

# Estimate models
out.1 <- glm(n.women.cand ~ sl.autob.n.women.elected + n.women.elected.lagged + n.women.cand.previously.elected + n.men.cand.previously.elected + n.women.cand.lagged + n.people.elected + n.cand + referenda + wom.kr + log.dist.zh + log.pop +  kr.svp + steuerfuss + agglo + land + as.factor(year), data=d, family="poisson")
summary(out.1)


# Descriptive statistics

mm <- model.frame(out.1)

cn <- c("Min.", "Max.", "Mean", "S.D.", "N")
ds <- matrix(NA, nrow=ncol(mm)-1, ncol=length(cn))
colnames(ds) <- cn

rn <- c(
	"Nr W candidates (t)",
	"Spatial lag",
	"Nr W/M elected (t-1)",
	"Nr W incumbent candidates (t)",
	"Nr M incumbent candidates (t)",
	"Nr W candidates (t-1)",
	"Nr seats in executive",
	"Total nr candidates",
	"Referenda on gender equal.",
	"Women in cantonal elec.",
	"Distance from Zurich (log)",
	"Population (log)",
	"Conservative party",
	"Tax level",
	"Suburb",
	"Country"
)

rownames(ds) <- rn

for(i in 1:ncol(mm)){
	ds[i,1] <- min(mm[,i])	
	ds[i,2] <- max(mm[,i])	
	ds[i,3] <- mean(mm[,i])	
	ds[i,4] <- sd(mm[,i])	
	ds[i,5] <- length(mm[,i])
}

print(ds)

xtable(ds)


